package com.example.month11.listview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.recyclerview01.R;
import java.util.List;

/**
 * 传统的使用。
 */
//public class MyAdapter extends BaseAdapter {

/*   public class MyAdapter<T> extends CommonAdapter<T> {
  public MyAdapter(Context context, List<T> mDatas)
    {
        super(context, mDatas);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        ViewHolder viewHolder = ViewHolder.get(mContext, convertView, parent,
                R.layout.lv_item, position);
        TextView mTitle = viewHolder.getView(R.id.id_tv_title);
        mTitle.setText((String) mDatas.get(position));
        return viewHolder.getConvertView();
    }*/


    /*private LayoutInflater mInflater;
    private Context mContext;
    private List<String> mDatas;

    public MyAdapter(Context context, List<String> mDatas) {
        mInflater = LayoutInflater.from(context);
        this.mContext = context;
        this.mDatas = mDatas;
    }
    @Override
    public int getCount() {
        return mDatas.size();
    }
    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }
    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // 实例化一个viewHolder
        ViewHolder viewHolder = ViewHolder.get(mContext, convertView, parent,
                R.layout.lv_item, position);
        // 通过getView获取控件
        TextView tv = viewHolder.getView(R.id.id_tv_title);
        //使用
        tv.setText(mDatas.get(position));
        return viewHolder.getConvertView();
    }*/

    /* @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.lv_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.mTextView = (TextView) convertView.findViewById(R.id.id_tv_title);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mTextView.setText(mDatas.get(position));
        return convertView;
    }
        private final class ViewHolder {
        TextView mTextView;
    }
    */
//}
